package com.ruoyi.common.exception;

import com.ruoyi.common.exception.backendEnum.*;
import com.ruoyi.common.exception.integrationEnum.MapRenderException;
import com.ruoyi.common.exception.schemeEnum.*;

/**
 * 业务异常
 * 
 * @author ruoyi
 */
public final class ServiceException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    /**
     * 错误码
     */
    private Integer code;

    /**
     * 错误提示
     */
    private String message;

    /**
     * 错误明细，内部调试错误
     *
     * 和 {@link //CommonResult#getDetailMessage()} 一致的设计
     */
    private String detailMessage;

    /**
     * 空构造方法，避免反序列化问题
     */
    public ServiceException()
    {
    }

    public ServiceException(String message)
    {
        this.message = message;
    }

    public ServiceException(String message, Integer code)
    {
        this.message = message;
        this.code = code;
    }

    public String getDetailMessage()
    {
        return detailMessage;
    }

    @Override
    public String getMessage()
    {
        return message;
    }

    public Integer getCode()
    {
        return code;
    }

    public ServiceException setMessage(String message)
    {
        this.message = message;
        return this;
    }

    public ServiceException setDetailMessage(String detailMessage)
    {
        this.detailMessage = detailMessage;
        return this;
    }

    public ServiceException(MineFileException mineFileException){
        this.message = mineFileException.getMessage();
        this.code = mineFileException.getCode();
    }

    public ServiceException(CameraException cameraException){
        this.message = cameraException.getMessage();
        this.code = cameraException.getCode();
    }

    public ServiceException(DustException dustException){
        this.message = dustException.getMessage();
        this.code = dustException.getCode();
    }

    public ServiceException(EcologicalDataException ecologicalDataException){
    	this.message = ecologicalDataException.getMessage();
    	this.code = ecologicalDataException.getCode();
    }

    public ServiceException(EcologicalSupervisionReportException ecologicalSupervisionReportException){
        this.message = ecologicalSupervisionReportException.getMessage();
        this.code = ecologicalSupervisionReportException.getCode();
    }

    public ServiceException(FieldException fieldException){
        this.message = fieldException.getMessage();
        this.code = fieldException.getCode();
    }

    public ServiceException(MineException mineException){
        this.message = mineException.getMessage();
        this.code = mineException.getCode();
    }

    public ServiceException(MineProductionException mineProductionException){
        this.message = mineProductionException.getMessage();
        this.code = mineProductionException.getCode();
    }

    public ServiceException(SatelliteException satelliteException){
        this.message = satelliteException.getMessage();
        this.code = satelliteException.getCode();
    }

    public ServiceException(SensorException sensorException){
        this.message = sensorException.getMessage();
        this.code = sensorException.getCode();
    }

    public ServiceException(SurveyException surveyException){
        this.message = surveyException.getMessage();
        this.code = surveyException.getCode();
    }

    public ServiceException(TasksException tasksException){
        this.message = tasksException.getMessage();
        this.code = tasksException.getCode();
    }

    public ServiceException(UavException uavException){
        this.message = uavException.getMessage();
        this.code = uavException.getCode();
    }

    public ServiceException(WeatherException weatherException){
        this.message = weatherException.getMessage();
        this.code = weatherException.getCode();
    }

    public ServiceException(RestorationProjectException restorationProjectException){
        this.message = restorationProjectException.getMessage();
        this.code = restorationProjectException.getCode();
    }

    public ServiceException(RestorationDataException restorationDataException){
        this.message = restorationDataException.getMessage();
        this.code = restorationDataException.getCode();
    }

    public ServiceException(FileUtilsException fileUtilsException){
        this.message = fileUtilsException.getMessage();
        this.code = fileUtilsException.getCode();
    }

    public ServiceException(SchemeException schemeException){
        this.message = schemeException.getMessage();
        this.code = schemeException.getCode();
    }

    public ServiceException(PatchException patchException){
        this.message = patchException.getMessage();
        this.code = patchException.getCode();
    }

    public ServiceException(MapRenderException mapRenderException){
        this.message = mapRenderException.getMessage();
        this.code = mapRenderException.getCode();
    }
}